<template>
	<view class="component">
		<sdc-navbar 
			title="" 
			:offBack="true"
			backText=""
			backIconName="plus"
		>
			<template slot="content">
				<view class="content">
					<u-tabs 
						:list="tabs" 
						:is-scroll="true" 
						:current="current" 
						@change="change"
						bg-color="#ffc659"
						active-color="#000000"
						bar-width="26"
						bar-height="8"
						height="65"
					></u-tabs>
				</view>
			</template>
			<template slot="right">
				<view  class="right">
					<u-icon name="search" size="44"></u-icon>
				</view>
			</template>
		</sdc-navbar>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	export default {
		props: {
			categoryId: {
				type: String,
				default: null
			}
		},
		data() {
			return {
				tabs: [],
				current: 0
			};
		},
		methods: {
			change(index){
				this.$emit('change',{tab:this.tabs[index]})
				this.current = index
			}
		},
		mounted() {
			
		},
		computed: {
			...mapState(['menuCategory'])
		},
		watch: {
			categoryId(){
				let category = this.menuCategory.find(item=>{
					return item.id == this.categoryId
				})
				if(category !== undefined){
					this.tabs = category.childlist
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.component{
		.right{
			padding: 0 $uni-spacing-row-base;
		}
		.content{
			background-color: #F3F4F6;
			width: 570upx;
		}
	}
</style>
